<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .container{
            display: grid; /*将container定义为栅格容器*/
            width: 300px;
            height: 300px;
            border: 1px solid;
            grid-template-rows: repeat(auto-fill,100px); /*自动填充 每个格子占100px*/
            grid-template-columns: repeat(auto-fill,100px);
        }
        .container >div{
            background-color: red;
            background-clip: content-box;
            border: 1px solid;
            padding: 10px;
            box-sizing: border-box;
        }

        /**********************************/

        .container2{
            display: grid; /*将container定义为栅格容器*/
            width: 300px;
            height: 300px;
            border: 1px solid;
            grid-template-rows: repeat(3,1fr); /*分成3行 每行占1份   fr是fraction(分数) 的缩写*/
            grid-template-columns: repeat(3,1fr);
        }
        .container2 >div{
            background-color: red;
            background-clip: content-box;
            border: 1px solid;
            padding: 10px;
            box-sizing: border-box;
        }
         /**********************************/
         .container3{
            display: grid; /*将container定义为栅格容器*/
            width: 300px;
            height: 300px;
            border: 1px solid;
            grid-template-rows: 1fr 2fr 1fr; /*分成3行 第一行占1/4 第二行占2/4 第三行占1/4*/
            grid-template-columns: 1fr 2fr 1fr;
        }
        .container3 >div{
            background-color: red;
            background-clip: content-box;
            border: 1px solid;
            padding: 10px;
            box-sizing: border-box;
        }
    </style>
</head>
<body>
    <div class="container">
        <div>1</div>
        <div>2</div>
        <div>3</div>
        <div>4</div>
        <div>5</div>
        <div>6</div>
        <div>7</div>
    </div>
    <hr />
    <div class="container2">
        <div>1</div>
        <div>2</div>
        <div>3</div>
        <div>4</div>
        <div>5</div>
        <div>6</div>
        <div>7</div>
    </div>

    <hr />
    <div class="container3">
        <div>1</div>
        <div>2</div>
        <div>3</div>
        <div>4</div>
        <div>5</div>
        <div>6</div>
        <div>7</div>
    </div>
</body>
</html>